<template>
  <el-table :data="tableData.list" :loading="loading" element-loading-text="加载中..." border border-radius
            :summary-method="getSummaries"
            show-summary
            @sort-change="sortChange"
  >
    <el-table-column
      align="center"
      prop="game"
      label="游戏名称">
      <template slot-scope="{row, $index}">
        <el-button type="link" size="small"
                   @click="showDetail(row)"
        >
          {{row.game}}
        </el-button>
      </template>
    </el-table-column>
    <el-table-column
      align="center"
      label="投注金额">
      <template slot-scope="{row}">
        {{row.amount | currency}}
      </template>
    </el-table-column>
    <el-table-column
      align="center"
      label="派彩金额">
      <template slot-scope="{row}">
        {{row.prize | currency}}
      </template>
    </el-table-column>
    <el-table-column
      align="center"
      label="有效投注金额">
      <template slot-scope="{row}">
        {{row.effectAmount | currency}}
      </template>
    </el-table-column>
    <el-table-column
      align="center"
      label="公司输赢">
      <template slot-scope="{row}">
        <money-text  :negate="true" :value="row.win"></money-text>
      </template>
    </el-table-column>


    <template slot="empty">
      <div class="el-table__empty">
        <svg-icon class="el-table__empty-icon" icon-class="grid-empty-2"></svg-icon>
        <div class="el-table-text">暂无数据</div>
      </div>
    </template>
  </el-table>
</template>

<script type="text/jsx">

  import {gameReportApi as getApi} from '@/services/api/report';

  import {grid} from '@/build';
  import commonMixins from './common';

  export default {

    name: "sub-member-game-win-lose",

    mixins: [grid, commonMixins],

    data() {
      return {
        filters: {
        },
        summariesText: '汇总',
        tableData: {
          list: [],
          total: 0,
        },
        statistic: [
          {
            index: 1,
            prop: 'tableData.sum.amount',
            format: (value) => {
              return <div>{_.currency(value)}</div>;
            }
          },
          {
            index: 2,
            prop: 'tableData.sum.prize',
            format: (value) => {
              return <div>{_.currency(value)}</div>;
            }
          },
          {
            index: 3,
            prop: 'tableData.sum.effectAmount',
            format: (value) => {
              return <div>{_.currency(value)}</div>;
            }
          },
          {
            index: 4,
            prop: 'tableData.sum.win',
            format: (value) => {
              return <money-text negate={true} value={value}></money-text>;
            }
          },
        ]
      };
    },

    methods:{
    	showDetail(row){
    		this.$emit('showBetDetail',row);
      }
    },

    mounted() {
      this.bindGet(getApi, 'tableData', {
        action: 'getGrid',
        sendingData: 'filters',
      });
      this.getAll();
    }
  };

</script>

